package org.feiye.studyday21;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionsTest {
	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		list.add("小王");
		list.add("你好");
		list.add("hello");
		list.add("哈哈");
		list.add("拉拉");
		list.add("ss");
		// 打印集合的最大最小值
		String strMax = (String) Collections.max(list);
		String strMin = (String) Collections.min(list);
		System.out.println(strMax + "\t" + strMin);
		System.out.println("...........................................");
		// 升序排序
		Collections.sort(list);
		for (String string : list) {
			System.out.println(string);
		}
		System.out.println("...........................................");
		// 查找
		int binarySearch = Collections.binarySearch(list, "1");
		int binarySearch2 = Collections.binarySearch(list, "哈哈");
		System.out.println(binarySearch + "\t" + binarySearch2);
		System.out.println("...........................................");
		// 反转集合元素(或降序 )
		Collections.reverse(list);
		for (String string : list) {
			System.out.println(string);
		}
	}
}
